

import delayPromise from "./delay_promise"

/**
 * 返回 Promise 类型的工具函数
 */

const promiseUtils = <T>(main: (success: (result: T) => void, fail: (error: any) => void) => void | Promise<T>) :Promise<T> => {
  if (main instanceof Promise ){
    return main
  }

  return new Promise((resolve, reject) => {
    main(resolve, reject)
  })
}

export default promiseUtils
